package com.bentley.kotlindemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView
import android.widget.Toast

class MringActivity1 : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_mring1)
        findViewById<TextView>(R.id.tv_test).text = "Hello Kotlin"
        findViewById<Button>(R.id.btn).setOnClickListener {
            //  Toast.makeText(this, "Hello Kotlin", Toast.LENGTH_LONG).show()
            val intent = Intent(this, MringActivity2::class.java)
            intent.putExtra("yud",true)
            startActivity(intent)
        }
        val tvTest = findViewById<TextView>(R.id.tv_test)
        tvTest.setTextColor(resources.getColor(R.color.black))
        tvTest.text = "我是你Kotlin"

        //   listFor()
        vars(1, 2, 3, 4, 5)
    }

    var items = listOf<String>("banner", "apple", "pear")
    fun listFor() {
        /* for (item in items) {
             Log.e("Kotlin===",item)
         }*/

        for (index in items.indices) {
            Log.e("Kotlin===", "item at $index is ${items[index]}")
        }
    }

    fun vars(vararg v: Int) {
        for (i in v) {
            Log.e("Kotlin===", i.toString());
        }
    }
}